package com.ruoyi.audit.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.domain.PartnersCashRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.audit.service.IPartnersCashRecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 合伙人提现记录Controller
 * 
 * @author ruoyi
 * @date 2021-03-24
 */
@RestController
@RequestMapping("/partner")
public class PartnersCashRecordController extends BaseController
{
    @Autowired
    private IPartnersCashRecordService partnersCashRecordService;

    /**
     * 查询合伙人提现记录列表
     */
    @PreAuthorize(hasPermi = "audit:partner:list")
    @GetMapping("/list")
    public TableDataInfo list(PartnersCashRecord partnersCashRecord)
    {
        startPage();
        List<PartnersCashRecord> list = partnersCashRecordService.selectPartnersCashRecordList(partnersCashRecord);
        return getDataTable(list);
    }

    /**
     * 导出合伙人提现记录列表
     */
    @PreAuthorize(hasPermi = "audit:partner:export")
    @Log(title = "合伙人提现记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PartnersCashRecord partnersCashRecord) throws IOException
    {
        List<PartnersCashRecord> list = partnersCashRecordService.selectPartnersCashRecordList(partnersCashRecord);
        ExcelUtil<PartnersCashRecord> util = new ExcelUtil<PartnersCashRecord>(PartnersCashRecord.class);
        util.exportExcel(response, list, "partner");
    }

    /**
     * 获取合伙人提现记录详细信息
     */
    @PreAuthorize(hasPermi = "audit:partner:query")
    @GetMapping(value = "/{cashid}")
    public AjaxResult getInfo(@PathVariable("cashid") Long cashid)
    {
        return AjaxResult.success(partnersCashRecordService.selectPartnersCashRecordById(cashid));
    }

    /**
     * 新增合伙人提现记录
     */
    @PreAuthorize(hasPermi = "audit:partner:add")
    @Log(title = "合伙人提现记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PartnersCashRecord partnersCashRecord)
    {
        return toAjax(partnersCashRecordService.insertPartnersCashRecord(partnersCashRecord));
    }

    /**
     * 修改合伙人提现记录
     */
    @PreAuthorize(hasPermi = "audit:partner:edit")
    @Log(title = "合伙人提现记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PartnersCashRecord partnersCashRecord)
    {
        return toAjax(partnersCashRecordService.updatePartnersCashRecord(partnersCashRecord));
    }

    /**
     * 删除合伙人提现记录
     */
    @PreAuthorize(hasPermi = "audit:partner:remove")
    @Log(title = "合伙人提现记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cashids}")
    public AjaxResult remove(@PathVariable Long[] cashids)
    {
        return toAjax(partnersCashRecordService.deletePartnersCashRecordByIds(cashids));
    }
}
